import numpy as np
import cv2
import os
#设定颜色HSV范围，假定为红色
Lower = np.array([15,0 ,0])
Upper = np.array([25,255, 255])

def car_Type(img):
    #将图像转化为HSV格式
    hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
    #去除颜色范围外的其余颜色
    mask = cv2.inRange(hsv, Lower,Upper)
    #cv2.imshow("mask",mask)
    row=len(mask)
    col=len(mask[0])
    count=0
    for i in range(0,row):
        for j in range(0,col):
           if mask[i][j]>200:
              count=count+1
    #如果指定颜色像素所占比例大于0.3，则认为该拍照为指定颜色
    if count/row/col>0.3: return '大型车'
    else: return '小型车'

